<template>
  <div id="wrap">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/activity' }">
        <i class="iconfont icon-qingdanguanli"></i>
        <span>促销活动</span>
      </el-breadcrumb-item>
    </el-breadcrumb>
    <div class="lines"></div>

    <!-- 头部按钮 -->

    <div class="header_btn">
      <el-button type="primary" @click="changetype1">活动类型管理</el-button>
      <el-button type="primary" @click="changetype2">活动管理</el-button>
    </div>

    <!-- 主体表单 -->

    <div class="main">
      <div class="hd_type" ref="type1">
        <!-- <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
        <el-menu-item index="1">新增活动</el-menu-item>
        <el-menu-item index="2">查看活动列表</el-menu-item>
        <el-menu-item index="">生成活动条形码</el-menu-item>
      </el-menu>
      <el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal" @select="handleSelect"
        background-color="#545c64" text-color="#fff" active-text-color="#ffd04b">
      </el-menu> -->
        <template class="tables">
          <el-tabs v-model="ruleForm.activeName" @tab-click="handleClick">
            <el-tab-pane label="新增活动" name="first">
              <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="活动名称" prop="activityName" class="act_name">
                  <el-input v-model="ruleForm.activityName"></el-input>
                </el-form-item>
                <el-form-item label="类别" prop="activityTypeId" class="act_leibie">
                  <el-select v-model="ruleForm.activityTypeId" placeholder="请选择活动类别">
                    <el-option label="促销" value="1"></el-option>
                    <el-option label="活动" value="2"></el-option>
                    <!-- <el-option label="买一送一" value="hd3"></el-option> -->
                  </el-select>
                </el-form-item>
                <el-form-item label="活动时间" required class="act_date">
                  <template>
                    <div class="block">
                      <!-- <el-date-picker v-model="ruleForm.activityStartTime" type="date" placeholder="开始日期">
                      </el-date-picker>
                      <el-date-picker v-model="ruleForm.activityEndTime" type="date" placeholder="结束日期">
                      </el-date-picker> -->
                      <el-date-picker v-model="ruleForm.activityStartTime" value-format="yyyy-MM-dd" type="date"
                        placeholder="开始日期">
                      </el-date-picker>
                      <el-date-picker v-model="ruleForm.activityEndTime" value-format="yyyy-MM-dd" type="date"
                        placeholder="结束日期">
                      </el-date-picker>
                    </div>
                  </template>
                </el-form-item>
                <div class="remaks">
                  <el-form-item label="备注" prop="activityContent" class="act_remarks">
                    <el-input type="textarea" v-model="ruleForm.activityContent" style="height:200px;"></el-input>
                  </el-form-item>
                  <div class="type">
                    <el-form-item label="状态" prop="activityStatus" class="act_type">
                      <el-radio v-model="ruleForm.activityStatus" label="0" @change="getValue()">开启</el-radio>
                      <el-radio v-model="ruleForm.activityStatus" label="1" @change="getValue()">关闭</el-radio>
                    </el-form-item>
                  </div>
                </div>
                <el-form-item class="act_btn">
                  <el-button type="primary" @click="submitForm('ruleForm')">添加</el-button>
                </el-form-item>
              </el-form>
            </el-tab-pane>

            <el-tab-pane label="查看活动列表" name="second">
              <div class="hdlist" ref="hdlist" id="hdlist">
                <template>
                  <el-table :data="tableData" :default-sort="{prop: 'activity_id', order: 'ascending'}"
                    style="width: 100%">
                    <el-table-column label="活动编号" sortable prop="activity_id">
                    </el-table-column>
                    <el-table-column label="活动名称" prop="activity_name">
                    </el-table-column>
                    <el-table-column label="类别" prop="activity_status">
                    </el-table-column>
                    <el-table-column label="开启时间" prop="activity_start_time">
                    </el-table-column>
                    <el-table-column label="结束时间" prop="activity_end_time">
                    </el-table-column>
                    <el-table-column label="备注" prop="activity_content">
                    </el-table-column>
                    <el-table-column label="状态">
                      <template scope="scope">
                        <el-button size="mini" @click="submitForm()">开启</el-button>
                        <el-button size="mini" type="danger"
                          @click="changelist(scope.$index, scope.row),adminActivity(scope.$index, scope.row)">
                          管理</el-button>
                      </template>
                    </el-table-column>
                  </el-table>
                </template>
              </div>

              <div class="list_gl" ref="list_gl">
                <div class="list_gl_header">
                  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                    <el-form-item label="一级类别" prop="goods_one_type_name">
                      <el-select @change="checkLeibie2" v-model="leibie" placeholder="请选择一级类别">
                        <el-option label="" :value="v.goods_one_type_name" v-for="(v,i) in goods_one_type_name"
                          :key="i">
                          {{v.goods_one_type_name}}</el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="二级类别" prop="region2">
                      <el-select v-model="leibie2" placeholder="请选择二级类别">
                        <el-option label="" :value="v.goods_two_type_name" v-for="(v,i) in goods_two_type_name"
                          :key="i">
                          {{v.goods_two_type_name}}</el-option>
                      </el-select>
                    </el-form-item>
                    <el-button type="success" style="margin-left:20px;" @click="(dialogVisible = true),checkGoods()">
                      查询商品
                    </el-button>
                  </el-form>
                </div>
                <div class="list_gl_main">
                  <template>
                    <el-table :data="table2Data" sortable="true" sort-by="ID" style="width: 100%">
                      <el-table-column label="ID" prop="activity_id">
                      </el-table-column>
                      <el-table-column label="条形码" prop="goods_bar_code">
                      </el-table-column>
                      <el-table-column label="商品名称" prop="goods_name">
                      </el-table-column>
                      <el-table-column label="数量" prop="activity_goods_count">
                      </el-table-column>
                      <el-table-column label="选择">
                        <template slot-scope="scope">
                          <el-button size="mini" type="danger" @click="handleDelete( scope.row,scope.$index)">删除
                          </el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                  </template>
                  <el-button type="primary" style="float:right;width:100px;margin-top:20px;" @click="changelist2">确定
                  </el-button>
                </div>
                <div class="dialog">
                  <el-dialog :visible.sync="dialogVisible" width="30%" style="positon:relative;">
                    <template>
                      <el-table ref="multipleTable" max-height="460px" :data="table3Data" tooltip-effect="dark"
                        style="width: 100%" @selection-change="handleSelectionChange">
                        <el-table-column type="selection" width="55">
                        </el-table-column>
                        <el-table-column prop="goods_name" label="商品名称" width="120">
                        </el-table-column>
                        <el-table-column prop="goods_bar_code" label="商品条码" width="120">
                        </el-table-column>
                        <el-table-column prop="goods_price" label="单价" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="goods_amount" label="商品库存" show-overflow-tooltip>
                        </el-table-column>
                      </el-table>

                    </template>
                    <span class="dialog-footer">
                      <el-button @click="dialogVisible = false">取 消</el-button>
                      <el-button type="primary" @click="dialogVisible = false,submitForm3()">确
                        定
                      </el-button>
                    </span>
                  </el-dialog>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="生成活动条形码" name="third">
              <el-form :model="ruleForm" :rules="rules2" ref="ruleForm" label-width="100px"
                class="demo-ruleForm hdselect">
                <el-form-item label="活动区域" prop="region2">
                  <el-select v-model="ruleForm.region2" placeholder="请选择活动名称">
                    <el-option label="手机类" value="FL1"></el-option>
                    <el-option label="家电类" value="FL2"></el-option>
                  </el-select>
                </el-form-item>
                <div class="hdbtn">
                  <el-button type="success" @click="payOrder">生成条形码</el-button>
                  <el-button type="primary" v-print="'#barcode'" :disabled="dis">打印条形码</el-button>
                </div>
              </el-form>
              <template>
                <div class="tiaoxingma" id="bar">
                  <!-- 条形码容器，可选svg、canvas，或img标签 -->
                  <svg id="barcode"></svg>
                </div>
              </template>
            </el-tab-pane>
          </el-tabs>
        </template>
      </div>

      <!-- 活动类型管理 -->

      <div ref="type2" class="type2">
        <template class="tables">
          <el-tabs v-model="activeName2" @tab-click="handleClick2">
            <el-tab-pane label="新增活动类型" name="first">

              <el-form :model="ruleForm2" :rules="rules" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
                <el-form-item label="名称" prop="activity_type_name" class="act_name2">
                  <el-input v-model="ruleForm2.activity_type_name"></el-input>
                </el-form-item>
                <el-form-item label="描述" prop="activity_type_content" class="act_miaoshu">
                  <el-input v-model="ruleForm2.activity_type_content"></el-input>
                </el-form-item>
                <el-form-item label="状态" prop="activity_status" class="act_type2">
                  <el-radio-group v-model="ruleForm2.activity_type_status">
                    <el-radio v-model="ruleForm2.activity_type_status" label="0" @change="getValue2()">开启</el-radio>
                    <el-radio v-model="ruleForm2.activity_type_status" label="1" @change="getValue2()">关闭</el-radio>
                  </el-radio-group>
                </el-form-item>
                <div class="hd_type_btn">
                  <el-button type="primary" class="insert_hd_type" @click="submitForm2()">添加</el-button>
                </div>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="查看活动类型" name="second">
              <template>
                <el-table :data="table4Data" style="width: 100%">
                  <el-table-column label="ID" prop="activity_type_id">
                  </el-table-column>
                  <el-table-column label="活动名称" prop="activity_type_name">
                  </el-table-column>
                  <el-table-column label="描述" prop="activity_type_content">
                  </el-table-column>
                  <el-table-column label="活动状态" prop="activity_type_status">
                    <template scope="scope" prop="activity_type_status">
                      <el-switch active-color="#13CE66" :active-value="1" :inactive-value="0" inactive-color="#F60100"
                        v-model="scope.row.activity_type_status"
                        @change="change(scope.$index,scope.row),typeChange(scope.$index,scope.row)">
                      </el-switch>
                    </template>
                  </el-table-column>
                </el-table>
              </template>
            </el-tab-pane>
          </el-tabs>
        </template>
      </div>
    </div>
  </div>
</template>
<style scoped>
#wrap {
  width: 100%;
}
#wrap .el-breadcrumb i {
  margin-right: 10px;
  font-size: 1.2rem;
}
#wrap .lines {
  margin-top: 20px;
  height: 1px;
  background: #bbb;
  width: 100%;
}
#wrap .header_btn {
  box-sizing: border-box;
  margin-top: 20px;
  padding-left: 30px;
  width: 100%;
  height: 70px;
  text-align: left;
  line-height: 70px;
  background: #eee;
  border-radius: 10px 10px;
}
#wrap .header_btn button:nth-child(2) {
  margin-left: 30px;
}
#wrap .header_btn button:hover {
  background: #deedf7;
  color: #409eff;
}
#wrap .main {
  box-sizing: border-box;
  padding-top: 20px;
  padding-left: 20px;
  padding-right: 20px;
  padding-bottom: 20px;
  margin-top: 20px;
  width: 100%;
  /* height: 600px; */
  background: #eee;
  overflow: hidden;
}
#wrap .main .hd_type {
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
}
#wrap .main ul {
  border-bottom: 1px sloid #bbb;
  background: none;
}
#wrap .main ul li {
  height: 50px;
}
#wrap .main ul li:hover {
  background: none;
}
#wrap .main ul .is-active {
  background: none;
}
#wrap .main .el-form {
  margin-left: 5%;
  margin-top: 20px;
}
#wrap .main .el-form .act_name,
#wrap .main .el-form .act_leibie {
  width: 40%;
  float: left;
}
#wrap .main .el-form .act_date {
  width: 40%;
  clear: both;
}
::v-deep .el-form .act_leibie .el-form-item__content {
  margin-left: 30px;
  width: 40%;
}
#wrap .main .el-form .act_leibie label {
  width: 100px;
}
#wrap .main .el-form .remaks {
  clear: both;
}
#wrap .main .el-form .remaks .act_remarks,
#wrap .main .el-form .type {
  float: left;
}
#wrap .main .el-form .act_remarks {
  width: 40%;
}
#wrap .main .el-form .act_remarks .el-input {
  height: 80px;
}
::v-deep .act_remarks .el-textarea__inner {
  height: 200px;
  padding-top: none;
}
::v-deep .el-form .act_type .el-form-item__content {
  margin-left: 30px;
  width: 40%;
}
::v-deep .el-form .act_type .el-form-item__content .el-radio-group label {
  float: left;
  margin-top: 15px;
}
::v-deep .el-form .act_type .el-form-item__content .el-radio-group label span {
  font-size: 1rem;
}
::v-deep .el-radio .el-radio__label {
  transform: translateY(10px);
}
#wrap .main .el-form .act_btn button {
  width: 200px;
}
#wrap .main .el-form .act_btn {
  clear: both;
  text-align: left;
}
#wrap .main .el-form .act_btn button:hover {
  background: #deedf7;
  color: #409eff;
}
#wrap .main .hdselect {
  position: relative;
}
::v-deep .hdselect .el-form-item .el-form-item__content {
  margin-left: 30px;
  width: 300px;
}
::v-deep .hdselect .el-form-item .el-form-item__content input {
  width: 350px;
}
::v-deep .hdselect .el-form-item {
  width: 450px;
}
::v-deep .hdselect .el-form-item {
  float: left;
}
::v-deep .hdselect button:nth-child(1) {
  position: absolute;
  left: 470px;
}
::v-deep .hdselect button:nth-child(2) {
  position: absolute;
  left: 590px;
}
.list_gl {
  display: none;
}
.act_miaoshu,
.act_name2 {
  margin-left: 20%;
  width: 40%;
}
.act_type2 {
  position: relative;
  clear: both;
  margin-left: 20%;
  /* height: 200px; */
}
.act_type2 .el-radio-group {
  position: absolute;
  left: 80px;
  top: 10px;
}
::v-deep .el-form .act_type2 .el-form-item__content {
  margin-left: 20px !important;
  width: 40%;
}
::v-deep .act_miaoshu .el-form-item__content {
  /* height: 200px; */
  height: 30px;
}
::v-deep .act_miaoshu .el-form-item__content input,
::v-deep .act_name2 .el-form-item__content input {
  width: 100%;
}
.type2 .el-form .el-form-item .el-form-item__content .el-input {
  position: relative;
}
.type2 {
  display: none;
}
.hd_type_btn {
  clear: both;
  margin-left: 400px;
}
.hd_type_btn button {
  width: 200px;
}

.el-form-item {
  float: left;
}
.tiaoxingma {
  text-align: center;
  clear: both;
  width: 50%;
  height: 165px;
  line-height: 165px;
  margin-left: 10%;
  margin-top: 50px;
  background: #eee;
}
::v-deep .el-dialog,
::v-deep .el-dialog__body,
::v-deep .el-dialog .el-table__body-wrapper,
::v-deep .el-dialogth th,
::v-deep .el-dialog td {
  background: #273238;
}
</style>
<script>
import jsbarcode from 'jsbarcode';
export default {
  data () {
    return {
      activeName: 'first',
      activeName2: 'first',
      dialogVisible: false,
      activity_type_status: '',
      value1: true,
      dis: true,
      ruleForm: {
        region: '',
        region2: '',
        delivery: false,
        type: [],
        activityContent: '',
        activityEndTime: '',
        activityName: '',
        activityStartTime: '',
        activityStatus: 1,
        activityTypeId: '',
      },
      ruleForm2: {
        activity_type_content: '',
        activity_type_name: '',
        activity_type_status: '',
      },
      rules: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 2, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
        ],
        region: [
          { required: true, message: '请选择活动类别', trigger: 'change' }
        ],
        desc: [
          { required: true, message: '请填写活动备注', trigger: 'blur' }
        ]
      },
      rules2: {
        region2: [
          { required: true, message: '请选择活动名称', trigger: 'change' }
        ],
      },
      tableData: [{
        activity_id: '001',
        activity_name: '华为P40',
        activity_status: '手机',
        activity_start_time: '2021/7/15',
        activity_end_time: '2021/7/16',
        activity_content: '华为手机'
      },
      {
        activity_id: '002',
        activity_name: '华为P40',
        activity_status: '手机',
        activity_start_time: '2021/7/15',
        activity_end_time: '2021/7/16',
        activity_content: '华为手机'
      },
      {
        activity_id: '005',
        activity_name: '华为P40',
        activity_status: '手机',
        activity_start_time: '2021/7/15',
        activity_end_time: '2021/7/16',
        activity_content: '华为手机'
      },
      {
        activity_id: '009',
        activity_name: '华为P40',
        activity_status: '手机',
        activity_start_time: '2021/7/15',
        activity_end_time: '2021/7/16',
        activity_content: '华为手机'
      }
      ],
      table2Data: [{
        activity_id: '',
        goods_two_type_name: '001',
        goods_name: 'iphone 12',
        goods_bar_code: '123456789000',
        activity_goods_count: '60',
      },
      {
        activity_id: '',
        goods_two_type_name: '',
        goods_name: '',
        goods_bar_code: '',
        activity_goods_count: '',
      }
        ,],
      table3Data: [
        {
          goods_name: '华为 p40',
          goods_bar_code: '123456789000',
          goods_amount: '60',
          goods_price: '6999',
        },
        {
          goods_name: '',
          goods_bar_code: '',
          goods_amount: '',
          goods_price: '',
        },],
      table4Data: [{
        activity_type_id: '01',
        activity_type_name: '促销',
        activity_type_content: '八折促销',
        activity_type_status: '',
      },
      {
        activity_type_id: '02',
        activity_type_name: '打折',
        activity_type_content: '五折促销',
        activity_type_status: '',
      },
      ],
      table5Data: [],
      taable6Data: [{},
      {},
      {}],
      leibie: '',
      leibie2: '',
      hdid: '',
      goods_one_type_name: '',
      goods_two_type_name: '',
      activity_id: '',
      multipleSelection: [],
      msg: '',
    }
  },
  methods: {
    btnType () {
      this.value2 = true;
      console.log(this.value2);
    },
    handleClick (tab, event) {
      console.log(tab, event);
    },
    handleClick2 (tab2, event2) {
      console.log(tab2, event2);
    },
    change (index, row) {
      console.log(index, row);
      console.log(row.activity_type_status)
    },
    // test () {
    //   console.log(this.ruleForm.activityStartTime)
    //   console.log(this.ruleForm.activityEndTime)

    // },
    submitForm () {
      let demo = parseInt(this.ruleForm.activityStatus);
      // console.log(this.ruleForm.activity_status)
      this.$axios.post('http://192.168.137.1:8080/admin/add_activity', {
        activityContent: this.ruleForm.activityContent,
        activityEndTime: this.ruleForm.activityEndTime,
        activityName: this.ruleForm.activityName,
        activityStartTime: this.ruleForm.activityStartTime,
        activityStatus: demo,
        activityTypeId: this.ruleForm.activityTypeId,
      }).then(res => {
        console.log(this.ruleForm.activityName)
        console.log(res);
        if (res.data.code == 200) {
          this.$message('添加成功')
        } else {
          this.$message('添加失败')
        }
      })
    },
    submitForm2 () {
      let demo = parseInt(this.ruleForm2.activity_type_status);
      // console.log(this.ruleForm.activity_status)
      this.$axios.get('http://192.168.137.1:8080/admin/add_activity_type', {
        params: {
          activity_type_content: this.ruleForm2.activity_type_content,
          activity_type_name: this.ruleForm2.activity_type_name,
          activity_type_status: demo,
        }
      }).then(res => {
        console.log(res);
        if (res.data.code == 200) {
          console.log(this.ruleForm2.activity_type_content)
          console.log(this.ruleForm2.activity_type_name)

          this.$message('添加成功')
        } else {
          this.$message('添加失败')
        }
      })
    },
    submitForm3 () {
      console.log(this.$refs.multipleTable.selection)
      // this.$refs.multipleTable.selection.push(this.table5Data)
      this.table5Data = this.$refs.multipleTable.selection
      this.table5Data[0].activity_id = this.hdid
      this.table5Data[1].activity_id = this.hdid
      this.table5Data[2].activity_id = this.hdid
      console.log(this.table5Data)
      this.taable6Data[0].activity_goods_count = this.table5Data[0].goods_amount
      this.taable6Data[0].activity_id = this.table5Data[0].activity_id
      this.taable6Data[0].goods_bar_code = this.table5Data[0].goods_bar_code
      this.taable6Data[0].goods_name = this.table5Data[0].goods_name
      this.taable6Data[0].goods_price = this.table5Data[0].goods_price

      this.taable6Data[1].activity_goods_count = this.table5Data[1].goods_amount
      this.taable6Data[1].activity_id = this.table5Data[1].activity_id
      this.taable6Data[1].goods_bar_code = this.table5Data[1].goods_bar_code
      this.taable6Data[1].goods_name = this.table5Data[1].goods_name
      this.taable6Data[1].goods_price = this.table5Data[1].goods_price

      this.taable6Data[2].activity_goods_count = this.table5Data[2].goods_amount
      this.taable6Data[2].activity_id = this.table5Data[2].activity_id
      this.taable6Data[2].goods_bar_code = this.table5Data[2].goods_bar_code
      this.taable6Data[2].goods_name = this.table5Data[2].goods_name
      this.taable6Data[2].goods_price = this.table5Data[2].goods_price
      console.log(this.taable6Data)
      console.log(this.$refs.multipleTable.selection[0].goods_amount)
      this.$axios.post('http://192.168.137.1:8080/admin/activity_add_goods', {
        activityGoods: this.taable6Data,
      }).then(res => {
        console.log(res);
        if (res.data.code == 200) {
          this.$message('添加成功')
        } else {
          this.$message('添加失败')
        }
      })
    },
    check () {
      this.$axios.get('http://192.168.137.1:8080/admin/select_activity', {
        params: {
          activity_content: '',
          activity_end_time: '',
          activity_name: '',
          activity_start_time: '',
          activity_status: '',
          activity_id: '',
        },
      }).then(res => {
        console.log(res);
        this.tableData = res.data.data
        if (res.data.code == 200) {
          this.$message('查询成功')
        } else {
          this.$message('查询失败')
        }
      })
    },
    check2 () {
      this.$axios.get('http://192.168.137.1:8080/admin/select_activity_type', {
        params: {
          activity_type_id: '',
          activity_type_name: '',
          activity_type_content: '',
          activity_type_status: '',
        },
      }).then(res => {
        console.log(res);
        this.table4Data = res.data.data
        if (res.data.code == 200) {
          this.$message('成功')
        } else {
          this.$message('失败')
        }
      })
    },
    check3 () {
      this.$axios.get('http://192.168.137.1:8080/admin/queryAllGoodsMsg', {
        params: {
          goods_name: '',
          activity_type_name: '',
          activity_type_content: '',
          activity_type_status: '',
        },
      }).then(res => {
        console.log(res);
        this.table3Data = res.data.data
        if (res.data.code == 200) {
          this.$message('成功')
        } else {
          this.$message('失败')
        }
      })
    },
    check4 (index, row) {
      console.log(index, row)
      this.$axios.get('http://192.168.137.1:8080/admin/select_activity_type', {
        params: {
          activity_type_id: '',
          activity_type_name: '',
          activity_type_content: '',
          activity_type_status: '',
        },
      }).then(res => {
        console.log(res);
        this.table4Data = res.data.data
        if (res.data.code == 200) {
          this.$message('成功')
        } else {
          this.$message('失败')
        }
      })
    },
    checkLeibie1 () {
      this.$axios.get('http://192.168.137.1:8080/admin/queryOneTypeName', {
        params: {
          goods_one_type_name: this.goods_one_type_name
        },
      }).then(res => {
        console.log(res);
        this.goods_one_type_name = res.data.data
        if (res.data.code == 200) {
          console.log(this.goods_one_type_name)
          this.$message({
            message: '成功',
            type: 'success'
          })
        } else {
          this.$message('失败')
        }
      })
    },
    typeChange (index, row) {
      console.log(index, row)
      this.$axios.get('http://192.168.137.1:8080/admin/update_activity_status', {
        params: {
          activity_id: row.this.table4Data.activity_type_id,
          activity_status: row.this.table4Data.activity_type_status
        },
      }).then(res => {
        console.log(res);
        this.activity_status = res.data.data
        console.log(this.goods_two_type_name)
        if (res.data.code == 200) {
          this.$message({
            message: '更改成功',
            type: 'success'
          })
        } else {
          this.$message('更改失败')
        }
      })
    },
    // demo () {
    //   console.log(123);
    // },
    checkLeibie2 () {
      this.$axios.get('http://192.168.137.1:8080/admin/queryTwoTypeName', {
        params: {
          goods_one_type_name: this.leibie
        },
      }).then(res => {
        console.log(res);
        this.goods_two_type_name = res.data.data
        console.log(this.goods_two_type_name)
        if (res.data.code == 200) {
          this.$message({
            message: '',
            type: 'success'
          })
        } else {
          this.$message('失败')
        }
      })
    },
    checkGoods () {
      console.log(this.leibie2)
      this.$axios.get('http://192.168.137.1:8080/admin/select_by_type_name', {
        params: {
          goods_two_type_name: this.leibie2,
          goods_name: '',
          goods_bar_code: '',
          goods_amount: '',
          goods_price: ''
        },
      }).then(res => {
        console.log(res);
        this.table3Data = res.data.data
        console.log(this.table2Data)
        if (res.data.code == 200) {
          this.$message({
            message: '',
            type: 'success'
          })
        } else {
          this.$message('失败')
        }
      })
    },

    resetForm (formName) {
      this.$refs[formName].resetFields();
    },
    handleEdit (index, row) {
      console.log(index, row);
    },
    handleWatch (index, row) {
      console.log(index, row);
    },
    handleDelete (row, index) {
      this.tableData.splice(index, 1)
      console.log(index, row)
      // console.log(this.tableData[index].activity_id)
      // console.log(this.table2Data[index].goods_bar_code)
      this.$axios.get('http://192.168.137.1:8080/admin/del_activity_goodsBy_activityID', {
        params: {
          activity_id: this.tableData[index].activity_id,
          goods_bar_code: this.table2Data[index].goods_bar_code,
        },
      }).then(res => {
        console.log(res);
        if (res.data.code == 200) {
          this.$message('删除成功')
        } else {
          this.$message('删除失败')
        }
      })
    },
    getValue () {
      // console.log(this.value);
      console.log(this.ruleForm.activityStatus)

    },
    getValue2 () {
      // console.log(this.value);
      console.log(this.ruleForm2.activity_type_status)

    },
    // 查询活动排序


    changetype1 () {
      this.$refs.type1.style.display = "none";
      this.$refs.type2.style.display = "block";
    },
    changetype2 () {
      this.$refs.type1.style.display = "block";
      this.$refs.type2.style.display = "none";
    },
    changelist (index, row) {
      console.log(index, row)
      this.hdid = row.activity_id;
      // console.log(this.hdid)
      this.$refs.hdlist.style.display = "none";
      this.$refs.list_gl.style.display = "block";
    },
    adminActivity (index, row) {
      console.log(row.activity_id)
      this.$axios.get('http://192.168.137.1:8080/admin/select_activity_goodsBy_activityID', {
        params: {
          activity_id: row.activity_id,
          goods_name: '',
          goods_bar_code: '',
          activity_goods_count: ''
        },
      }).then(res => {
        console.log(res);
        this.table2Data = res.data.data
        console.log(this.goods_two_type_name)
        if (res.data.code == 200) {
          this.$message({
            message: '管理',
            type: 'success'
          })
        } else {
          this.$message('失败')
        }
      })
    },
    changelist2 () {
      this.$refs.hdlist.style.display = "block";
      this.$refs.list_gl.style.display = "none";
    },
    toggleSelection (rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange (val) {
      this.multipleSelection = val;
    },
    payOrder () {
      this.dis = false;
      jsbarcode(
        '#barcode',
        '1234567890000',
        {
          displayValue: true // 是否在条形码下方显示文字
        }
      );
    },
  },
  mounted () {
    // this.activityList();
    // this.hdlist();
    this.checkLeibie1()
    this.check()
    this.check2()
  }
}
</script>
